package com.xz.courseschedule.controller;

import com.xz.courseschedule.ai.ChatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * AI聊天控制器
 * @Author: zys
 * @CreateTime: 2025-05-29
 */
@Tag(name = "AI聊天", description = "AI智能对话和咨询服务")
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;

    @Operation(summary = "AI问答", description = "向AI提问并获取流式响应，支持排课相关咨询")
    @PostMapping("/ask")
    public Flux<String> ask(@RequestBody String userQuestion) {
        return chatService.getAiResponse(userQuestion);  // 直接返回Flux流
    }
}